﻿<%@ include file="/WEB-INF/jsp/include.jsp" %>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #F8F9FA;
}
-->

</style>

<link href="<%=request.getContextPath()%>/images/skin.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/images/fox.css" rel="stylesheet" type="text/css" />
<script src="<%=request.getContextPath()%>/js/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/nyroModal.css" type="text/css" media="screen" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/nyroModal-1.6.2/js/jquery.nyroModal-1.6.2.min.js"></script>
<script src="<%=request.getContextPath()%>/js/pub/pub.js" type="text/javascript"></script>
<script src="<%=request.getContextPath()%>/js/doorscrm/orders/add_orders_doors.js" type="text/javascript"></script><body>
<form name="form1" method="post" id="form1" action="">
<table width="103%" border="0" cellpadding="0" cellspacing="0">
	<input name="pid" type="hidden" id="pid" value="${orderid}"/>
	<input name="productno" type="hidden" id="productno" value=""/>
	<input name="type" type="hidden" id="type" value="${type}"/>
  <tr>
    <td width="17" height="29" valign="top" background="<%=request.getContextPath()%>/images/mail_leftbg.gif"><img src="<%=request.getContextPath()%>/images/left-top-right.gif" width="17" height="29" /></td>
    <td width="944" height="29" valign="top" background="<%=request.getContextPath()%>/images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">木门下单</div></td>
      </tr>
    </table></td>
    <td width="27" valign="top" background="<%=request.getContextPath()%>/images/mail_rightbg.gif"><img src="<%=request.getContextPath()%>/images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td height="71" valign="middle" background="<%=request.getContextPath()%>/images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="100%" height="138" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td height="13" valign="top">&nbsp;</td>
      </tr>
      <tr>
        <td height="13" valign="top">
        	 <ul class="navt">
        	 		<c:forEach items="${ProductType_list}" var="pt" >
                <li><a <c:if test="${type==pt.id}"> class="navdq"</c:if> <c:if test="${type!=pt.id}"> class="navdqt"</c:if> href="<%=request.getContextPath()%>/redirect/addorderdetails/${orderid}/${pt.id}">新增${pt.name}</a></li>
               </c:forEach>

            </ul>
        	</td>
      </tr>
      <tr>
        <td valign="top"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="nowtable">
              <tr>
                <td class="left_bt2"><div align="center">新增订单信息</div></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td>
                <table width="100%" height="90" border="0" cellpadding="0" cellspacing="0">
                  <tr >
                    <td colspan="9" align="center" bgcolor="#f2f2f2" class="tda"><div align="left"><strong>基础信息</strong></div></td>
                    </tr>
                  <tr>
                    <td width="11%" rowspan="3" align="center" class="tda"><strong>基本信息</strong></td>
                    <td width="9%" class="tda"><div align="center">款式系列</div></td>
                    <td width="12%" class="tda">
                    <select name="sery" id="sery" onChange="productsery_onchange()">
                       <option value="-1">请选择</option>
                    </select></td>
                    <td width="11%" class="tda">
                    	<select name="productid" id="productid" onChange="productid_onchange()">
                      	 <option value="-1">请选择</option>
                    	</select></td>
                    <td width="13%" class="tda"><div align="center">单价</div></td>
                    <td width="13%" align="center" class="tda"><div align="left">
                      <input type="text" style="color=red" name="single_price" id="single_price" value="0" size="10" class="button01" />
                      元</div></td>
                    <td class="tda"><div align="center">数量</div></td>
                    <td width="11%" align="center" class="tda"><div align="left">
                        <input type="text" style="color=red" name="number" id="number" value="" size="4" class="button01" />
                      套 </div></td>
                    <td width="10%" rowspan="6"  align="center" class="tda"><input type="button" name="calculate" id="calculate" onClick="calculate_func()" value="计算"></td>
                  </tr>
                  <tr>
                    <td class="tda"><div align="center">用途</div></td>
                    <td class="tda"><select name="func" id="func">
                      <option value="-1">请选择</option>
                      <option value="卧室门">卧室门</option>
                      <option value="书房门">书房门</option>
                      <option value="厨房">厨房</option>
                      <option value="卫生间">卫生间</option>
                      <option value="隔断门">隔断门</option>
                      <option value="其它">其它</option>
                                        </select></td>
                    <td class="tda"><div align="center">面板材料</div></td>
                    <td class="tda"><select name="facetableid" id="facetableid"  onChange="optation_onchange(1)" >
                      <option value="-1">请选择</option>
                       <c:forEach items="${ProductTable_list_1}" var="pt" >
                         <option value="${pt.id}">${pt.name}</option>
                       </c:forEach>
                       <option value="0">其它</option>
                    </select></td>
		                    <td align="center" class="tda" ><div align="left" style="display:none;" id="facetable_qt_id_1" >
		                      <input type="text" style="color=red" name="facetable" id="facetable" value="" size="10" class="button01" />
		                    </div></td>
		                    <td align="center" class="tda" > <span style="display:none;" id="facetable_qt_id_2" >单价</span></td>
		                    <td align="center" class="tda"><div align="left" style="display:none;" id="facetable_qt_id_3" >
		                      <input type="text" style="color=red" name="facetable_qt_price" id="facetable_qt_price" value="" size="4" class="button01" />
		                    元</div></td>
               		       </tr>
                  <tr>
                    <td align="center" class="tda">颜色</td>
                    <td align="center" class="tda"><div align="left">
                      <div align="left">
                        <input type="text" style="color=red" name="colour" id="colour" value="" size="15" class="button01" />
                      </div>
                    </div>                      <div align="left"></div></td>
                    <td align="center" class="tda"><div align="center">线条类</div>
                      <div align="left"></div></td>
                    <td class="tda"><select name="doorslineid" id="doorslineid" onChange="optation_onchange(2)">
                        <option value="-1">请选择</option>
                        <c:forEach items="${ProductTable_list_2}" var="pt" >
                         <option value="${pt.id}">${pt.name}</option>
                       </c:forEach>
                       <option value="0">其它</option>
                    </select></td>

	                    <td align="center" class="tda"><div align="left"  style="display:none;" id="doorsline_qt_id_1">
	                      <input type="text" style="color=red" name="doorsline" id="doorsline" value="" size="10" class="button01" />
	                    </div></td>
	                    <td align="center" class="tda"> <span style="display:none;" id="doorsline_qt_id_2">单价</span></td>
	                    <td align="center" class="tda"><div align="left" style="display:none;" id="doorsline_qt_id_3">
	                        <input type="text" style="color=red" name="doorsline_qt_price" id="doorsline_qt_price" value="" size="4" class="button01" />
	                      元</div></td>
                     </tr>
                  <tr>
                    <td rowspan="3" align="center" bgcolor="#f2f2f2" class="tda"><strong>原始信息</strong></td>
                    <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda">是/否门洞尺寸
                      <label></label>                      <label></label></td>
                    <td align="center" bgcolor="#f2f2f2" class="tda"><label>
                      <input type="radio" name="ishole" value="1" id="ishole">
是</label>
                      <label>
                      <input type="radio" name="ishole" value="0" id="ishole">
否</label></td>
                    <td align="center" bgcolor="#f2f2f2" class="tda">是/否单丁墙
                      <label>
                    
                      <div align="left"></div>
                    </label></td>
                    <td align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                      <select name="issingle" id="issingle"  >
                        <option value="-1">请选择</option>
                        <option value="0">正常</option>
                        <option value="1">单丁墙</option>
                        <option value="2">双单丁墙</option>
                      </select>
                    </div></td>
                    <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda"><label></label>
                      <label>
                      <div align="left" style="display:none;" id="issingle_num_id" >扣除：
                        <input type="text" style="color=red" name="issingle_num" id="issingle_num" value="0" size="5" class="button01" />
                        毫米</div>
                      </label></td>
                    </tr>
                    <tr>
                      <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda">是/否已扣除地砖</td>
                      <td align="center" bgcolor="#f2f2f2" class="tda"><label>
                        <input type="radio" name="isthick" value="1" id="isthick" onClick="isthicked(1)">
是</label>
                        <label>
                        <input type="radio" name="isthick" value="0" id="0" onClick="isthicked(0)">
否</label></td>
                      <td align="center" bgcolor="#f2f2f2" class="tda">
                        <div align="left" style="display:none;" id="isthick_false_value_id">
                          <select name="isthick_false_value" id="isthick_false_value" >
                            <option value="-1">请选择</option>
                            <option value="1">木地板</option>
                            <option value="2">地砖</option>
                            <option value="3">强化地板</option>
                        </select>                         </div></td>
                      <td align="center" bgcolor="#f2f2f2" class="tda">&nbsp;</td>
                      <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda">&nbsp;</td>
                      </tr>
                    <tr>
                      <td align="center" bgcolor="#f2f2f2" class="tda">高</td>
                      <td align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                          <input type="text" style="color=red" name="originalhigh" id="originalhigh" value="" size="8" class="button01" />
                          毫米</div></td>
                      <td align="center" bgcolor="#f2f2f2" class="tda">宽</td>
                      <td align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                          <input type="text" style="color=red" name="originalwidth" id="originalwidth" value="" size="8" class="button01" />
                          毫米</div></td>
                      <td align="center" bgcolor="#f2f2f2" class="tda">厚</td>
                      <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda"><div align="left">
                          <input type="text" style="color=red" name="originallength" id="originallength" value="" size="10" class="button01" />
                          毫米</div></td>
                      </tr>
                    <tr>
                      <td colspan="9" align="center" bgcolor="#f2f2f2" class="tda"><div align="left"><strong>以下系统自动计算
                        
                      </strong></div></td>
                    </tr>
                    <tr>
                      <td rowspan="2" align="center" class="tda"><strong>线条信息</strong></td>
                      <td align="center"  class="tda">线条1</td>
                      <td align="center"  class="tda">长(毫米)</td>
                      <td align="center" class="tda"><div align="left">
                          <input type="text" style="color=red" name="doorslinelength" id="doorslinelength" value="" size="15" class="button01" />
                      </div></td>
                      <td align="center" class="tda">数量</td>
                      <td align="center" class="tda"><div align="left">
                          <input type="text" style="color=red" name="doorslinenum" id="doorslinenum" value="0" size="8" class="button01" />
                        根 </div></td>
                      <td align="center" class="tda">&nbsp;</td>
                      <td colspan="2" align="center" class="tda">&nbsp;</td>
                    </tr>
                    <tr>
                    <td align="center"  class="tda">线条2</td>
                    <td align="center"  class="tda">长(毫米)</td>
                    <td align="center" class="tda"><div align="left">
                        <input type="text" style="color=red" name="doorslinelength2" id="doorslinelength2" value="" size="15" class="button01" />
                    </div></td>
                    <td align="center" class="tda">数量</td>
                    <td align="center" class="tda"><div align="left">
                      <input type="text" style="color=red" name="doorslinenum2" id="doorslinenum2" value="0" size="8" class="button01" />
                      根 </div></td>
                    <td width="10%" align="center" class="tda">&nbsp;</td>
                    <td colspan="2" align="center" class="tda"><div align="left"></div></td>
                    </tr>
                   <tr>
                       <td rowspan="2" align="center" bgcolor="#f2f2f2" class="tda"><strong>净尺寸</strong></td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">门扇</td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">高(毫米)</td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="confirmhigh" id="confirmhigh" value="" size="15" class="button01" />
                         </div></td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">宽(毫米)</td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="confirmwidth" id="confirmwidth" value="" size="15" class="button01" />
                         </div></td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">厚(毫米)</td>
                       <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="confirmlength" id="confirmlength" value="" size="15" class="button01" />
                         </div></td>
                    </tr>
                  <tr>
                       <td align="center" bgcolor="#f2f2f2" class="tda">门套</td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">高(毫米)</td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="tbconfirmhigh" id="tbconfirmhigh" value="" size="15" class="button01" />
                         </div></td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">宽(毫米)</td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="tbconfirmwidth" id="tbconfirmwidth" value="" size="15" class="button01" />
                         </div></td>
                       <td align="center" bgcolor="#f2f2f2" class="tda">厚(毫米)</td>
                       <td colspan="2" align="center" bgcolor="#f2f2f2" class="tda">
                         <div align="left">
                           <input type="text" style="color=red" name="tbconfirmlength" id="tbconfirmlength" value="" size="15" class="button01" />
                         </div></td>
                    </tr>
                  <tr>
                    <td align="center" class="tda"><strong>备注：</strong></td>
                    <td colspan="8" class="tda"><span id="sprytextarea1">
                      <label>
                        <textarea name="remark" id="remark" cols="45" rows="3">&nbsp;</textarea>
                        </label>
                    </span></td>
                    </tr>
                   <tr>
                    <td  align="center" bgcolor="#f2f2f2" class="tda"><strong>总价：</strong></td>
                    <td colspan="7"  align="center" bgcolor="#f2f2f2" class="tda"><div align="left" >
                      <input type="text" style="color=red" name="price" id="price" value="0" size="10" class="button01" />
                    元</div></td>
                    <td  align="center" bgcolor="#f2f2f2" class="tda">&nbsp;</td>
                    </tr>
                 
                  <tr>
                    <td colspan="9" align="center" class="tda">
                      <input type="button" name="button" id="button" value="确定并下单" onClick="go_submit()">                  
                       <input type="button" name="button" onClick="re_back()" id="button" value="返回列表">                        </td>
                    </tr>
                  <tr>
                    <td>&nbsp;&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                </table>             </td>
          </tr>
          
        </table>
          </td>
      </tr>
    </table></td>
    <td background="<%=request.getContextPath()%>/images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="middle" background="<%=request.getContextPath()%>/images/mail_leftbg.gif"><img src="<%=request.getContextPath()%>/images/buttom_left2.gif" width="17" height="17" /></td>
      <td height="17" valign="top" background="<%=request.getContextPath()%>/images/buttom_bgs.gif"><img src="<%=request.getContextPath()%>/images/buttom_bgs.gif" width="17" height="17" /></td>
    <td background="<%=request.getContextPath()%>/images/mail_rightbg.gif"><img src="<%=request.getContextPath()%>/images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
</form>
</body>
<script type="text/javascript">
jQuery(function($) {
		var msg="${msg}";
		if(msg!="") alert(msg);
		producttype_onchange();
	});
//产品类型
function producttype_onchange(){
		$.getJSON("<%=syscontextPath %>/basicinfo/findProductSeryList/${type}",
		    function(data){
		    		$("#sery").empty();
		    		$("#sery").append("<option value='-1'>请选择</option>");
					  $.each(data, function(k, v) {
								$("#sery").append("<option value='"+v.id+"'>"+v.name+"</option>");
						});
				}
		);
}

//产品系列
function productsery_onchange(){
	var t=$('#sery').val();
	$.getJSON("<%=syscontextPath %>/product/findProductList/"+t,
	    function(data){
	    	$("#productid").empty();
	    	$("#productid").append("<option value='-1'>请选择</option>");
				 $.each(data, function(k, v) {
				 			 var v_id=v.id;
							 $("#productid").append("<option value='"+v_id+"'>"+v.productno+"</option>");
							 var p_a=new Array();
							 p_a[0]=v_id;
							 p_a[1]=v.price;
							 product_arr[k]=p_a;
					});
			}
	);
	
}
//显示
function optation_onchange(t){
	if(t==1){
			var facetable=$('#facetableid').val();
			if(facetable==0){
				$('#facetable').val('');
				$('#facetable_qt_id_1').show();
				$('#facetable_qt_id_2').show();
				$('#facetable_qt_id_3').show();
			}else{
				$('#facetable').val($('#facetableid').find("option:selected").text());
				$('#facetable_qt_id_1').hide();
				$('#facetable_qt_id_2').hide();
				$('#facetable_qt_id_3').hide();
			}
	}
	if(t==2){
			var doorsline=$('#doorslineid').val();
			if(doorsline==0){
				$('#doorsline').val('');
				$('#doorsline_qt_id_1').show();
				$('#doorsline_qt_id_2').show();
				$('#doorsline_qt_id_3').show();
			}else{
				$('#doorsline').val($('#doorslineid').find("option:selected").text());
				
				$('#doorsline_qt_id_1').hide();
				$('#doorsline_qt_id_2').hide();
				$('#doorsline_qt_id_3').hide();
			}
	}
	
}

//计算尺寸
function calculate_func(){
	if (checkform()) {
			$.post('<%=syscontextPath %>/calculate/doors', 
			        {pid:$('#pid').val(),productid:$('#productid').val(),number:$('#number').val(),
			        	facetableid:$('#facetableid').val(),facetable_qt_price:$('#facetable_qt_price').val(),
			        	doorslineid:$('#doorslineid').val(),doorsline_qt_price:$('#doorsline_qt_price').val(),
			        	ishole:getRadioValue(document.form1.ishole),isthick:getRadioValue(document.form1.isthick),
			        	issingle:$('#issingle').val(),isthick_false_value:$('#isthick_false_value').val(),
			        	originalhigh:$('#originalhigh').val(),originalwidth:$('#originalwidth').val(),
			        	originallength:$('#originallength').val(),single_price:$('#single_price').val()
			        	},
			         function(data) {
				
				   //先清空
				  $('#doorslinelength').val('');
					$('#doorslinenum').val('');  
					$('#doorslinelength2').val('');
					$('#doorslinenum2').val('');  
					$('#confirmhigh').val('');  
					$('#confirmwidth').val('');  
					$('#confirmlength').val(''); 
					$('#tbconfirmhigh').val('');  
					$('#tbconfirmwidth').val('');  
					$('#tbconfirmlength').val('');  
				  $('#price').val('');	
				
				   //设值
				  $('#doorslinelength').val(data.doorslinelength);
					$('#doorslinenum').val(data.doorslinenum);  
					
					$('#doorslinelength2').val(data.doorslinelength2);
					$('#doorslinenum2').val(data.doorslinenum2);  
			
					$('#confirmhigh').val(data.confirmhigh);  
					$('#confirmwidth').val(data.confirmwidth);  
					$('#confirmlength').val(data.confirmlength); 
					 
					$('#tbconfirmhigh').val(data.tbconfirmhigh);  
					$('#tbconfirmwidth').val(data.tbconfirmwidth);  
					$('#tbconfirmlength').val(data.tbconfirmlength);  
				
				  $('#price').val(data.price);	
				
			},"json");
		//$("#form1").submit();
		}
}
//提交
function go_submit(){
		if (checkform()&&form_submit()) {	 
				//序 列化表格元素 (类似 '.serialize()' 方法) 返回 JSON 数据结构数据
			  var	content = $("#form1").serializeArray();
				$.post('<%=syscontextPath %>/orders/addOrderDetail/${orderid}', content, function(data) {
					if (data.flag) {
						alert("保存成功！");
						if(confirm("需要继续新增吗？")){
							location.href="<%=request.getContextPath()%>/redirect/addorderdetails/${orderid}/1";
						}else{
							 location.href="<%=syscontextPath %>/orders/findOrderById/${orderid}";
						}
					} else {
						alert("保存失败！");
						
					}
				},"json");
	}
}
//返回
function re_back(){
	if(confirm("确认返回订单列表？"))
	  location.href="<%=syscontextPath %>/orders/findOrderById/${orderid}";
}
</script>